import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { Language } from "../../../../../extend/language/Language";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { SWrestleFightRecordInfo } from "../../../../../Message/Public/SWrestleFightRecordInfo";
import { PlayerUtil } from "../../common/util/PlayerUtil";
import { CareerConfig } from "../../../resource/CareerConfig";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class WrestleViedoCellRenderer
    
    export  class WrestleViedoCellRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            var loc1=GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat1);
            this._bmpWinSmall = new Object /* flash.display.Bitmap */();
            this._bmpWinSmall.x = 5;
            this._bmpWinSmall.y = 4;
            this.addChild(this._bmpWinSmall);
            this._tfName1 = ObjCreate.createTextField("", 35, 13, 180, 20, this, loc1);
            this._tfCareer1 = ObjCreate.createTextField("", 215, 13, 60, 20, this, loc1);
            this._tfWarfare1 = ObjCreate.createTextField("", 275, 13, 65, 20, this, loc1);
            ObjCreate.createBitmap(ImagesConst.ArenaVS, 350, -5, this);
            this._bmpLoseSmall = new Object /* flash.display.Bitmap */();
            this._bmpLoseSmall.x = 400;
            this._bmpLoseSmall.y = 4;
            this.addChild(this._bmpLoseSmall);
            this._tfName2 = ObjCreate.createTextField("", 435, 13, 180, 20, this, loc1);
            this._tfCareer2 = ObjCreate.createTextField("", 615, 13, 60, 20, this, loc1);
            this._tfWarfare2 = ObjCreate.createTextField("", 675, 13, 65, 20, this, loc1);
            this._tfName1.addEventListener(flash.events.TextEvent.LINK, this.onClickName1);
            this._tfName2.addEventListener(flash.events.TextEvent.LINK, this.onClickName2);
            this._btnWatch = ObjCreate.createGButton(Language.getString(42341), 740, 8, 50, 22, this);
            this._btnWatch.addEventListener(flash.events.MouseEvent.CLICK, this.onClickWatch);
            ObjCreate.createBg(5, 40, 790, 2, this, "SplitLine");
            LoaderHelp.addResCallBack(ResFileConst.arena, this.onRecCompl);
            return;
        }

        /* internal  */onRecCompl(): void
        {
            this._bmpWinSmall.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaWinSmall);
            this._bmpLoseSmall.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaLoseSmall);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "swrestlefightrecordinfo") 
            {
                this._recordInfo = arg1 as SWrestleFightRecordInfo;
                this.updateView();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            this._tfName1.htmlText = "<a href=\'event: 1\'><u>" + PlayerUtil.getProxyAndNameByEntityIdAndName(this._recordInfo.winPlayer.entityId, this._recordInfo.winPlayer.name) + "</u></a>";
            this._tfCareer1.text = CareerConfig.instance.getInfoByCode(this._recordInfo.winPlayer.career).name;
            this._tfWarfare1.text = this._recordInfo.winPlayer.warfare.toString();
            this._tfName2.htmlText = "<a href=\'event: 1\'><u>" + PlayerUtil.getProxyAndNameByEntityIdAndName(this._recordInfo.losePlayer.entityId, this._recordInfo.losePlayer.name) + "</u></a>";
            this._tfCareer2.text = CareerConfig.instance.getInfoByCode(this._recordInfo.losePlayer.career).name;
            this._tfWarfare2.text = this._recordInfo.losePlayer.warfare.toString();
            return;
        }

        /* internal  */onClickName1(arg1: Object /* flash.events.TextEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.WrestleGetPlayerInfo, this._recordInfo.winPlayer.entityId));
            return;
        }

        /* internal  */onClickName2(arg1: Object /* flash.events.TextEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.WrestleGetPlayerInfo, this._recordInfo.losePlayer.entityId));
            return;
        }

        /* internal  */onClickWatch(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._recordInfo) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.WrestleWatchViedo, this._recordInfo.fightRecordId));
            }
            return;
        }

        /* internal */ /* var */_recordInfo: SWrestleFightRecordInfo;

        /* internal */ /* var */_bmpWinSmall: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfName1: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfCareer1: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfWarfare1: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpLoseSmall: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfName2: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfCareer2: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfWarfare2: Object /* flash.text.TextField */;

        /* internal */ /* var */_btnWatch: GButton;
    }
